<div id="cate_bang_xep_hang" class="w670 left">
    <div class="title_cate_bxh box_width_common dot_bottom">
        <div class="left txt_title_cate_bxh"><b><?php echo $this->leagueDetail['Name'] ?></b> <span class="txt_gray"> | <?php echo date('d - m - Y', $this->maxUpdateTime); ?></span></div>
        <div class="right">
            <select class="right w150 leagua" onchange="tableRanking.changeTable(this.value)">
                <?php $i = 0; foreach($this->allLeague as $league){ ?>
                <option <?php if ($this->leagueDetail['LeagueID'] == $league['LeagueID']) echo 'selected="selected"'; ?> value="<?php echo $league['LeagueID']; ?>"><?php echo $league['Name']; ?></option>
                <?php $i++;if($i == 7 ) break;} ?>
            </select>
            <select class="right w150 year" onchange="tableRanking.changeTable(<?php echo $this->leagueDetail['LeagueID'] ?>, this.value);">
                <?php foreach($this->arrSeasonByLeague as $season){ ?>
                <option <?php if ($this->seasonDetail['SeasonID'] == $season['SeasonID']) echo 'selected="selected"'; ?> value="<?php echo $season['SeasonID']; ?>"><?php echo $season['NameSeason']; ?></option>
                <?php } ?>
            </select>
        </div>
        <div class="clear">&nbsp;</div>
    </div>
    <?php 
    $numberTeam = count($this->tableRanking);
    if ($numberTeam){
    ?>
    <div class="content_bxh">
        <table class="table_bxh">
            <tr class="top">
                <td class="w40">Vị trí</td>
                <td class="w190"><b class="txt_tendoi">Tên đội</b></td>
                <td class="w40">Trận</td>
                <td class="w40">Thắng</td>
                <td class="w40">Hòa</td>
                <td class="w40">Thua</td>
                <td class="w40">G.Bàn</td>
                <td class="w60">L.Lưới</td>
                <td class="w40">H.Số</td>
                <td class="w40">Điểm</td>
                <td class="w60">(*)</td>
            </tr>
            <?php 

            $i = 0;
            foreach($this->tableRanking as $teamID => $teamRanking){
                $className = '';
                if($i < 3 || $i >= $numberTeam - 3)
                    $className = 'no1';
                else if ($i == 3 || $i == 4)
                    $className = 'no2';
                $posChangIcon = 'icon_up';
                if ($teamRanking['PosChange'] == 1)
                    $posChangIcon = 'icon_down';
                else if ($teamRanking['PosChange'] == 2)
                    $posChangIcon = 'icon_deuce';
            ?>
            <tr class="<?php echo $className; ?>">
                <td class="w40"><?php echo $teamRanking['Position']; ?></td>
                <td class="w190"> <span class="icon_portal_thethao <?php echo $posChangIcon; ?>">&nbsp;</span> <?php echo $teamRanking['Name'] ?></td>
                <td class="w40"><?php echo $teamRanking['NumMatch'];?></td>
                <td class="w40"><?php echo $teamRanking['Won'];?></td>
                <td class="w40"><?php echo $teamRanking['Drawn'];?></td>
                <td class="w40"><?php echo $teamRanking['Lost'];?></td>
                <td class="w40"><?php echo $teamRanking['GoalScore'];?></td>
                <td class="w60"><?php echo $teamRanking['GoalAgainst'];?></td>
                <td class="w40"><?php echo $teamRanking['GoalDiffenrence'];?></td>
                <td class="w40"><b><?php echo $teamRanking['Point'];?></b></td>
                <td class="w60">
                    <ul class="list_info_5tran">
                        <?php 
                        if (!empty ($teamRanking['LastGameResult'])){
                        $resultLast5 = explode(',', $teamRanking['LastGameResult'], 6);
                        unset ($resultLast5[5]);
                        foreach ($resultLast5 as $resultMatch){
                            $resultMatch = intval($resultMatch);
                            $classWin = '';
                            if ($resultMatch == 3)
                                $classWin = 'win';
                            else if ($resultMatch == 0)
                                $classWin = 'lose';
                        ?>
                        <li class="<?php echo $classWin; ?>"><span>&nbsp;</span></li>
                        <?php }} ?>
                    </ul>
                </td>
            </tr>
            <?php 
            $i++;
            } ?>
        </table>
        <div class="txt_decs_bxh box_width_common">
            <div class="left"><b>(*)</b> Kết quả 5 trận đấu gần đây nhất</div>
            <div class="right">
                <span class="win icon_status">&nbsp;</span> <b>Thắng</b>       <span class="duce icon_status">&nbsp;</span> <b>Hòa</b>       <span class="lose icon_status">&nbsp;</span> <b>Thua</b>
            </div>
        </div>
    </div>
    <?php }else{ ?>
    <div class="content_bxh">
        Hiện tại chưa có giá trị bảng xếp hạng
    </div>
    <?php } ?>
</div> 
<script>
    $(document).ready(function(){
        tableRanking.init({
            url: '<?php echo BASE_URL; ?>',
            leagueId: <?php echo $this->leagueID; ?>,
            seasonId: <?php echo $this->seasonID; ?>,
            data:{
                leagues: <?php echo $this->arrLeagueJson; ?>,
                seasons: <?php echo $this->arrSeasonJson; ?>
            }
        });
    })
</script>
